package cn.fz.ssedemo.service;

import cn.fz.ssedemo.dao.AdminMapper;
import cn.fz.ssedemo.domain.po.AdminEntity;
import cn.fz.ssedemo.exception.BizException;
import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class AdminService extends ServiceImpl<AdminMapper, AdminEntity> implements IService<AdminEntity> {

    public AdminEntity login(String username, String password) {
        AdminEntity one = lambdaQuery().eq(AdminEntity::getAdminNo, username).one();
        if (ObjUtil.isEmpty(one)){
            throw new BizException(username + " 用户名不存在");
        }
        return one;
    }
}
